package com.tywj.lib.core.widget.recycleview

import androidx.annotation.ColorInt
import com.tywj.lib.core.common.util.AppUtil
import com.yanyusong.y_divideritemdecoration.Y_Divider
import com.yanyusong.y_divideritemdecoration.Y_DividerBuilder
import com.yanyusong.y_divideritemdecoration.Y_DividerItemDecoration

/**
 * <pre>
 *     author : June Yang
 *     time   : 2020/6/12
 *     desc   : RecyclerView item分割线
 *     version: 1.0.0
 * </pre>
 */
class DividerItemDecoration : Y_DividerItemDecoration(AppUtil.context) {

    private val dividerBuilder = Y_DividerBuilder()

    fun setLeftSideLine(
        widthDp: Float,
        @ColorInt color: Int,
        startPaddingDp: Float = 0f,
        endPaddingDp: Float = 0f
    ): DividerItemDecoration {
        dividerBuilder.setLeftSideLine(true, color, widthDp, startPaddingDp, endPaddingDp)
        return this
    }

    fun setTopSideLine(
        widthDp: Float,
        @ColorInt color: Int,
        startPaddingDp: Float = 0f,
        endPaddingDp: Float = 0f
    ): DividerItemDecoration {
        dividerBuilder.setTopSideLine(true, color, widthDp, startPaddingDp, endPaddingDp)
        return this
    }

    fun setRightSideLine(
        widthDp: Float,
        @ColorInt color: Int,
        startPaddingDp: Float = 0f,
        endPaddingDp: Float = 0f
    ): DividerItemDecoration {
        dividerBuilder.setRightSideLine(true, color, widthDp, startPaddingDp, endPaddingDp)
        return this
    }

    fun setBottomSideLine(
        widthDp: Float,
        @ColorInt color: Int,
        startPaddingDp: Float = 0f,
        endPaddingDp: Float = 0f
    ): DividerItemDecoration {
        dividerBuilder.setBottomSideLine(true, color, widthDp, startPaddingDp, endPaddingDp)
        return this
    }

    override fun getDivider(itemPosition: Int): Y_Divider = dividerBuilder.create()
}